package cn.xjt.screenShare.netty.decoder;

import cn.xjt.screenShare.netty.share.CaptureImage;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
@ChannelHandler.Sharable
public class ImageEncoder extends MessageToByteEncoder<CaptureImage> {

	@Override
	protected void encode(ChannelHandlerContext ctx, CaptureImage msg, ByteBuf out) throws Exception {
		System.out.println("写入数据"+msg.getLength());
		out.writeInt(msg.getLength());
		out.writeBytes(msg.getContent());
	}
}
